﻿using System.Collections.ObjectModel;
using System.Windows;
using Fluent;
using System.Windows.Controls;

namespace Infrastructure.Services
{
    /// <summary>
    /// Ribbon management services
    /// </summary>
    public class RibbonService : IRibbonService
    {
        /// <summary>
        /// Application menu
        /// </summary>
        public ObservableCollection<UIElement> ApplicationMenu { get; set; }

        /// <summary>
        /// Add a split item menu to the application menu
        /// </summary>
        /// <param name="menu">The menu item used as a parent node for the new menu item</param>
        /// <param name="menuItem">The new menu item</param>
        public void AddSplitMenuItem(RibbonMenu menu, Fluent.Button menuItem)
        {
            switch (menu)
            {
                case RibbonMenu.ExportList:
                    BackstageTabItem exportMenu = null;
                    foreach (object oItem in ApplicationMenu)
                    {
                        var item = oItem as BackstageTabItem;
                        if (item != null && item.Name == "ExportMenu")
                        {
                            exportMenu = item;
                            break;
                        }
                    }
                    ListBox exportList = (ListBox)exportMenu.Content;
                    exportList.Items.Add(menuItem);
                    exportMenu.IsEnabled = true;
                    break;
            }
        }
    }

    /// <summary>
    /// Ribbon menu identifiers
    /// </summary>
    public enum RibbonMenu
    {
        ExportList
    }
}